package cn.lf.controller;


import cn.lf.dto.sys.user.*;
import cn.lf.service.ISysUserService;
import cn.lf.utils.ResponseModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author guoyy
 * @since 2024-04-01
 */
@RestController
@RequestMapping("/sysuser")
@Api(tags = "用户信息接口")
public class SysUserController {

    @Autowired
    private ISysUserService sysUserService;

    @GetMapping("/getUserPage")
    @ApiOperation("获取用户列表 分页")
    public ResponseModel<IPage<UserListGetRepDTO>> queryUserPage(UserListGetReqDTO params){

        IPage<UserListGetRepDTO> result = sysUserService.queryUserPage(params);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("/setUserStatus")
    @ApiOperation("设置用户状态")
    public ResponseModel setUserStatus(@RequestBody UserStatusSetReqDTO userStatusSetReqDTO){

        sysUserService.setUserStatus(userStatusSetReqDTO);

        return ResponseModel.buildSuccessResult();
    }

    @GetMapping("/getUserInfoById")
    @ApiOperation("根据id获取用户详细信息")
    public ResponseModel<UserInfoGetRepDTO> getUserInfoById(@RequestParam String userId){

        UserInfoGetRepDTO result = sysUserService.getUserInfoById(userId);

        return ResponseModel.buildSuccessResult(result);
    }

    @PostMapping("/setUserInfo")
    @ApiOperation("设置用户信息")
    public ResponseModel setUserInfo(@RequestBody UserInfoSetReqDTO userInfoSetReqDTO){

        sysUserService.setUserInfo(userInfoSetReqDTO);

        return ResponseModel.buildSuccessResult();
    }

}
